Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing DB by URL when using docker compose #19

Open
RomanShushakov opened this issue Dec 2, 2023 · 12 comments
Open

Accessing DB by URL when using docker compose #19

RomanShushakov opened this issue Dec 2, 2023 · 12 comments

Comments

@RomanShushakov
Copy link

Hello everyone,

Sorry for newbie question, when I run redis and postgres examples locally everything works fine, but when I tried to run redis and postgres examples by using docker the following errors appear:

  1. For redis example
    redis_example_issue

  2. For postgres example
    postgres_example_issue

After studying "A complete microservice demo example which works fine, I added DNS_SERVER: 127.0.0.11:53 variable in docker-compose file at postgres and redis example.
postgres_example_changes

Postgres example works now.
postgres_example_works

But this trick not works for redis example. If you have some time, could you please help me to manage with issue in redis example?

Thanks,
Roman

@juntao
Copy link
Member

juntao commented Dec 2, 2023

Can you send your Docker compose file for the Redis app? Thanks!

@RomanShushakov
Copy link
Author

Thank you for response, sure

docker-compose.txt

@juntao
Copy link
Member

juntao commented Dec 2, 2023

Is it possible that the Redis container has not had the time to start up when Wasm service tried to connect? Perhaps introduce a delay like the health check you had with Postgres?

@RomanShushakov
Copy link
Author

Hello @juntao

I've added healthcheck for "cache" service, unfortunately it does not help.

redis_example_issue(1)

The docker-compose and healthcheck files I used were uploaded into attachment

Thanks,
Roman

docker-compose.txt
redis.txt

@CaptainVincent
Copy link
Member

I conducted an experiment by attempting to into other the ubuntu container, but running in the same service (same network) environment, to use redis-cli for accessing the cache. However, I was unable to establish a connection. And redis-cli directly from the host worked fine. I suspect there might be a configuration missing in the Docker network rather than an issue with the wasm runtime itself.
But I'll continue to see what else can help clarify the issue.

@RomanShushakov
Copy link
Author

Hello @CaptainVincent

Thank you for your response, I'll also play with docker network config, if I found smth interesting, I'll let you know.

Thanks,
Roman

@RomanShushakov
Copy link
Author

Hello @CaptainVincent

I still don't know that the true reason of this issue, but I was able to make some progress. When I inspected "cache" container and used the "IPAddress" directly in my docker compose everything become works fine, but using any network aliases invokes "os error 85" as it was before.

image

docker-compose.txt

Thanks,
Roman

@juntao
Copy link
Member

juntao commented Dec 8, 2023

Thank you Roman for investigating this.

It is interesting that the gateway IP address, not the server's IP address, worked for you. I wonder if you could start a regular Ubuntu container in the same compose and have it nslookup the DNS name cache? My guess is that it cannot -- but that would give us a simple case to raise an issue for the Docker team.

@RomanShushakov
Copy link
Author

Hello @juntao

I forgot to mention that both IPAddress and Gateway values work. Also I followed your recommendation and run "nslookup" "cache" command from Ubuntu container put in the same compose and it shows the appropriate IPAddress of cache service.
But I not understand why "REDIS_URL: redis://cache/" not work :-)

Thanks,
Roman

docker inspect

nclookup cache

docker-compose.txt

@juntao
Copy link
Member

juntao commented Dec 9, 2023

You know one thing I could think of is to change the host name from cache to something like rediscachehost because the word "cache" might have special meaning in Docker compose?

@RomanShushakov
Copy link
Author

Hello @juntao

I already tried this trick, but unfortunately it does not help :-)

Thanks,
Roman

docker-compose.txt

@RomanShushakov
Copy link
Author

Hello @juntao

I've some progress regarding this issue. If I use AsyncComand instead Command, with switching on appropriate feature for redis_wasi in Cargo.tom redis_wasi = { version = "0.22.3", features = ["tokio-comp"] } everything works fine.

Changes in code:

let mut con = client.get_async_connection().await?;
let _ : () = con.set("current_time", time).await?;
let value : String = con.get("current_time").await?;

Thanks,
Roman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants